<?php
/******************DB相关*********************/
define('DB_DEV_SERVER',	false);
defined('DB_DEBUG') || define('DB_DEBUG', false);
//	数据超过记录开始反转
defined('REVERSE_NUM')       || define('REVERSE_NUM', 5000);
define('DB_ERROR_LOG',	false);
//	define('DB_ERROR_LOG_FILE',     "/opt/wwwroot/qun_inner/cache/sql_error_log/db_error.log");
//	捕获执行时间大于n秒的sql,只可短暂开启
define('CAPTURE_LONGSQL_TIME',          0); //捕获大于该秒数的sql语句，(>0 && DB_DEBUG===false时为开启)
//	define('CAPTURE_LONGSQL_LOG_FILE',      "/opt/wwwroot/qun_inner/cache/sql_error_log/");

define('DB_RET_RES',        	'RES');
define('DB_RET_ROW',        	'ROW');
define('DB_RET_ROWS',       	'ROWS');
define('DB_RET_VALUE',      	'VALUE');
define('DB_RET_ROWS_PAGE',  	'ROWS_PAGE');
define('DB_DEFAULT_PAGE_SIZE', 	24);

/********************data source ************************************/
function &get_data_source($const_db, $param = null, $need_hash = true) 
{

    $hash				= ($param && $need_hash) ? md5($param) : null;
    $user				= null;
    $pass				= null;
    $port				= null;
    $table				= null;
    $table_alias		= null;

 /********************************************************************/
    switch ($const_db)
    {	
		case 'act':
			$mysqlCFG = get_act_mysql();
			$host			= $mysqlCFG['host'];
			$user			= $mysqlCFG['user'];
            $pass			= $mysqlCFG['passwd'];
            $database		= 'dmz_act_basic_2013';
            $table			= '';
			unset($mysqlCFG);
            break;
		case 'bill':
			$mysqlCFG = get_dmz_mysql_bill();
			$host			= $mysqlCFG['host'].':'.$mysqlCFG['port'];
			$user			= $mysqlCFG['user'];
            $pass			= $mysqlCFG['passwd'];
            $database		= '';
            $table			= '';
			unset($mysqlCFG);
            break;
		case 'carnival_present100':
			$mysqlCFG = get_dmz_mysql_zone_100();
			$host			= $mysqlCFG['host'].':'.$mysqlCFG['port'];
			$user			= $mysqlCFG['user'];
            $pass			= $mysqlCFG['passwd'];
            $database		= '';
            $table			= '';
			unset($mysqlCFG);
            break;
        default :
            $ret	= array();
            return $ret;
    }

 /********************************************************************/

    $ret = array(   
    		'host'				=> $host.($port ? ":{$port}" : ''),
			'user'				=> is_null($user) ? "root" : $user,
			'pass'          	=> is_null($pass) ? "" : $pass,
			'database'      	=> $database,
			'table'         	=> $table,
			'table_alias'		=> $table_alias
	);
	
    return $ret;
}
### end data source ###########################################################
?>
